package edu.udlap.spring2008.is300.finalexam.framework.mvc.view;

import edu.udlap.spring2008.is300.finalexam.framework.mvc.controller.Controller;

/**
 *
 * @author Ruslán Ledesma Garza
 */
public abstract class ViewRootCompositeComponent
        extends ViewCompositeComponent
{
    
    ///constructors...
    public ViewRootCompositeComponent(Controller controller)
    {
        setController(controller);
    }
    
    ///controller (strategy) management...
    @Override
    public void setController(Controller controller)
    {
        ///tell the old controller that it should talk no more
        ///to this composite root object...
        if(this.controller_ != null)
            this.controller_.setView(null);
        
        super.setController(controller);
        
        ///tell the controller that it should talk to this composite root object...
        if(controller_ != null)
            controller_.setView(this);
        
        ///set initial state of the composite tree (if any)...
        if(controller_ != null)
            controller_.initializeView();
    }
}
